package propaga.dados;

import propaga.xml.HandlerXML;
import propaga.grafos.Aresta;

import java.awt.Image;
import java.awt.List;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class ConnURL {

//    private final String USER_AGENT = "Mozilla/5.0";
	public static void main(String[] args) throws Exception {
		ConnURL http = new ConnURL();
	    
        String url = "http://www.geoservicos.ibge.gov.br/geoserver/ows?service=WMS&version=1.1.1&request=GetCapabilities";
//        		+ "&typeName=CCAR:e1000_curva_nivel&maxFeatures=10&outputFormat=text/xml;%20subtype=gml/3.1.1"
//        		+ "&propertyName=CCAR:id_curva_nivel,CCAR:cota,CCAR:geom";

        List textoXML = new HandlerXML().carregaWMS(url);

        System.out.println();
        System.out.println("--------------------------------------------------------------------");
        System.out.println();
        
        url = "http://www.geoservicos.ibge.gov.br/geoserver/ows?service=WFS&version=2.0.0&request=GetCapabilities";
//		+ "&typeName=CCAR:e1000_curva_nivel&maxFeatures=10&outputFormat=text/xml;%20subtype=gml/3.1.1"
//		+ "&propertyName=CCAR:id_curva_nivel,CCAR:cota,CCAR:geom";

        textoXML = new HandlerXML().carregaWFS(url);
	}
	
	public StringBuffer sendGet(String caminho) throws Exception {
        StringBuffer response = new StringBuffer();

        URL obj = new URL(caminho);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
        con.setRequestMethod("GET");
        con.setRequestProperty("Content-Type", "text-xml");
        
         BufferedReader in = new BufferedReader(
        	new InputStreamReader(con.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        return response;
    }
	
}
